package com.eternal.base.concat;

import androidx.room.Ignore;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator
 * On 2020/4/24
 * Description:
 * @author Administrator
 */
public class DeviceInfo {
    public static final byte INCREASE_TREND=1;
    public static final byte DECREASE_TREND=-1;
    public static final byte NORMAL_TREND=0;

    public String mac;
    public String name;
    public String typeName;
    public byte type;
    public long connectTime;
    public int tmp;
    public int hum;
    public int fan;
    public boolean isDegree;
    public byte tmpState;
    public byte humState;
    public byte fanState;
    public byte fanType; //0x00:控制器的风扇档位 0x01:插座的开关 0x02:植物灯的亮度档位
    @Ignore
    public List<PortInfo> portList;
    public byte port;
    public byte choosePort; // 当前选中的端口
    public boolean isPlug;

    public DeviceInfo() {
        mac="asdfsad";
        name="New Device";
        type=1;
        typeName ="NEM";
        tmp =40;
        hum =50;
        fan =60;
        isDegree=true;
        tmpState=1;
        humState =-1;
        fanState=1;
        connectTime =System.currentTimeMillis();
        portList = new ArrayList<>();
    }

    public void update(DeviceTFP deviceTFP) {
        isDegree = deviceTFP.isDegree;
        tmp = deviceTFP.tmp;
        hum =deviceTFP.per;
        fan = deviceTFP.fan;
        tmpState = deviceTFP.tmpState;
        humState = deviceTFP.humState;
        choosePort = deviceTFP.choosePort;
        if (portList != null) {
            for (PortInfo port1 : deviceTFP.portList) {
                for (PortInfo port2 : portList) {
                    if (port1.id == port2.id) {
                        port1.name = port2.name;
                    }
                }
            }
        }
        portList = deviceTFP.portList;
        fanType = deviceTFP.fanType;
        fanState = deviceTFP.fanState;
    }
}
